﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	查询首页
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="screen_area">
        <form method="Get" action="/Query/StackWater">
        <div>
        <%if ((bool)ViewData["showFactory"])
            {%>
        请选择公司：<%= Html.DropDownList("factoryId", ViewData["factories"] as List<SelectListItem>, "请选择公司", new { onchange = "showStacks();" })%>
        <span style="margin-left:20px"></span>
        <%
            }
            else
            {
        %>
        <%=Html.Hidden("factoryId", ViewData["factoryId"]) %>
        <%
            }
        %>
        <label>请选择堆场/尾矿库：</label><span id="stackList"><%= Html.DropDownList("stackId", ViewData["stacksAndTailingponds"] as List<SelectListItem>, "请选择", new { onchange = "showStackDateRange();" })%></span>
        <span style="margin-left:20px"></span>
        <label>查询日期：</label><span><input type="text" name="date" id="date" size="12" value="" class="ipt_date" readonly="readonly" /></span>
        <span><input type="submit" value="查  询" /></span>
        </div>
        </form>
    </div>

    <script type="text/javascript" language="javascript">
        $('#date').datepicker({ changeMonth: true, changeYear: true });

        function showStacks() {
            var factoryId = document.getElementById("factoryId").value;
            if (factoryId == "" || factoryId == 0) return;
            $.ajax({ 
                    type: "POST",
                    url: "<%=Url.Content("~/Modification/ListStacks") %>",
                    data: "factoryId=" + factoryId,
                    success: function (data) { $("#stackList").html(data);}
            });
        }

        function showStackDateRange() {
            var id = document.getElementById("stackId").value;
            var vars = id.split("-");
            var showType = vars[0];
            var stackId = vars[1];
            $('#date').datepicker("destroy");
            if (showType == 0) {
                $.ajax({ 
                        type: "POST",
                        url: "<%=Url.Content("~/Stack/GetDateRange") %>",
                        data: "stackId=" + stackId,
                        success: function (data) { 
                            var beginYear = data.BeginYear;
                            var endYear = data.EndYear;
                            $('#date').datepicker({ changeMonth: true, changeYear: true, reverseYearRange: 1, yearRange: beginYear + ":" + endYear });
                        }
                });
            }
            else {
                $('#date').datepicker({ changeMonth: true, changeYear: true });
            }
        }
    </script>
</asp:Content>
